import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Map<Character, Character> map = new HashMap<>();
        String a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String num =   "22233344455566677778889999";
        char[] ach = a.toCharArray();
        char[] numch = num.toCharArray();
        for (int i = 0; i < ach.length; i++) {
            map.put(ach[i], numch[i]);
        }
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            in.nextLine();
            String[] ss = new String[n];
            String[] sss = new String[n];
            for (int i = 0; i < ss.length; i++) {
                ss[i] = in.nextLine();
            }
            for (int i = 0; i < n; i++) {
                String s = ss[i];
                String r = "";
                for(int j = 0; j < s.length(); j++){
                    char ch = s.charAt(j);
                    if(ch-'0'>=0 && ch-'0'<=9){
                        r += ch;
                    }else if( ch == '-'){

                    }else{
                        r += map.get(ch);
                    }
                }
                r = r.substring(0,3) + "-" + r.substring(3);
                ss[i] = r;
            }
            for(int i = 0; i < n; i++){
                System.out.println(ss[i]);
            }
            System.out.println();
        }
    }
}